import { Injectable } from '@angular/core';
import { Action, State, StateContext } from '@ngxs/store';
import { Seller, Tab } from './seller.actions';

export interface SellerModel {
  tabs: Tab[];
  activeStoreId?: number;
}

@State<SellerModel>({
  name: 'seller',
  defaults: {
    tabs: [
      {title: '商品管理', link: '/seller/goods'},
      {title: '店铺管理', link: '/seller/store'},
    ],
  },
})
@Injectable({
  providedIn: 'root',
})
export class SellerState {
  @Action(Seller.Active)
  activeStore({patchState}: StateContext<SellerModel>, {id}: Seller.Active) {
    patchState({
      activeStoreId: id,
    });
  }
}
